package com.topgay.domain;

import java.io.Serializable;
import java.util.ArrayList;

public class MatchInfo implements Serializable, Comparable<MatchInfo>{
	private String	id;
	private String 	nickname;
	private float	matchPercent;
	private int		isLogin;
	private ArrayList<AnswerForFYTL> answerList;
	public MatchInfo(String id, String nickname, int isLogin,
			ArrayList<AnswerForFYTL> answerList) {
		super();
		this.id = id;
		this.nickname = nickname;
		this.isLogin = isLogin;
		this.answerList = answerList;
	}
	
	public MatchInfo(String id, String nickname, float matchPercent, int isLogin) {
		super();
		this.id = id;
		this.nickname = nickname;
		this.matchPercent = matchPercent;
		this.isLogin = isLogin;
	}

	public MatchInfo() {
		super();
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public float getMatchPercent() {
		return matchPercent;
	}
	public void setMatchPercent(float matchPercent) {
		this.matchPercent = matchPercent;
	}
	public int getIsLogin() {
		return isLogin;
	}
	public void setIsLogin(int isLogin) {
		this.isLogin = isLogin;
	}
	public ArrayList<AnswerForFYTL> getAnswerList() {
		return answerList;
	}
	public void setAnswerList(ArrayList<AnswerForFYTL> answerList) {
		this.answerList = answerList;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + isLogin;
		result = prime * result + Float.floatToIntBits(matchPercent);
		result = prime * result
				+ ((nickname == null) ? 0 : nickname.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MatchInfo other = (MatchInfo) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (isLogin != other.isLogin)
			return false;
		if (Float.floatToIntBits(matchPercent) != Float
				.floatToIntBits(other.matchPercent))
			return false;
		if (nickname == null) {
			if (other.nickname != null)
				return false;
		} else if (!nickname.equals(other.nickname))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "MatchInfo [id=" + id + ", nickname=" + nickname
				+ ", matchPercent=" + matchPercent + ", isLogin=" + isLogin
				+ "]";
	}

	@Override
	public int compareTo(MatchInfo o) {
		int result = 0;
		
		if(this.matchPercent == o.getMatchPercent()){
			result = 0;
		}else if(this.matchPercent > o.getMatchPercent()){
			result = -1;
		}else if(this.matchPercent < o.getMatchPercent()){
			result = 1;
		}
			
		return result;
	}
	
}
